package member;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.IdGeneratorStrategy;

@PersistenceCapable
public class Member {
	
	//Key is created by Datastore
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
	
    @Persistent
    private String name;
    
    @Persistent
    private String nickName;
    
    @Persistent
    private int score; 
    
    @Persistent
    private int transTimes;
    
    @Persistent
    private int point;
	
    @Persistent
    private boolean requirement;  //�臬�箇恣�
    
    public Member(String name, String nickName, int score, int transTimes, int point, boolean requirement){//嚙踝蕭嚙褓伐蕭嚙稽
        this.name = name;
        this.nickName = nickName;
        this.score = score;
        this.transTimes = transTimes;
        this.point = point;
        this.requirement = requirement;
    }
    
    public Member(){
        this.name = "None";
        this.nickName = "None";
        this.score = 0;
        this.transTimes = 0;
        this.point = 0;
        this.requirement = false;
    }
    
    public Member(String name){
        this.name = name;
        this.nickName = "None";
        this.score = 0;
        this.transTimes = 0;
        this.point = 0;
        this.requirement = false;
    }
    
    public Member(String name, String nickName){
        this.name = name;
        this.nickName = nickName;
        this.score = 0;
        this.transTimes = 0;
        this.point = 0;
        this.requirement = false;
    }
    
    
    public Long getId(){
        return id;
    }

    public String getName(){
        return name;
    }
    
    public String getNickName() {
		return nickName;
	}
    
    public int getScore(){
        return score;
    }
    public int getTransTimes(){
    		return transTimes;
    }
    public int getPoint(){
    		return point;
    }
    
    public boolean getRequirement(){
		return requirement ;
    }
    
    public int averageScore(int newScore){
    	score = (score*transTimes+newScore)/(transTimes+1);
    	transTimes++;
    	return score;
    }
    
    public void stock(String nickName){
    	this.nickName = nickName;
    }
	
    
} //Member
